<?php
// 检查users表结构
require_once 'utils/Database.php';

try {
    $db = new Database();
    
    // 检查表结构
    $columns = $db->fetchAll("DESCRIBE users");
    
    echo "<h2>users表结构:</h2>";
    echo "<table border='1'>";
    echo "<tr><th>字段名</th><th>类型</th><th>是否为空</th><th>键</th><th>默认值</th><th>额外</th></tr>";
    
    foreach ($columns as $column) {
        echo "<tr>";
        echo "<td>" . $column['Field'] . "</td>";
        echo "<td>" . $column['Type'] . "</td>";
        echo "<td>" . $column['Null'] . "</td>";
        echo "<td>" . $column['Key'] . "</td>";
        echo "<td>" . $column['Default'] . "</td>";
        echo "<td>" . $column['Extra'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    
    // 检查是否有用户数据
    $userCount = $db->fetchOne("SELECT COUNT(*) as count FROM users");
    echo "<h3>用户总数: " . $userCount['count'] . "</h3>";
    
    if ($userCount['count'] > 0) {
        $sampleUser = $db->fetchOne("SELECT * FROM users LIMIT 1");
        echo "<h3>示例用户数据:</h3>";
        echo "<pre>" . print_r($sampleUser, true) . "</pre>";
    }
    
} catch (Exception $e) {
    echo "<h2>错误</h2>";
    echo "<p>" . $e->getMessage() . "</p>";
}
?>